/*!
 * vinculum
 * Copyright(c) 2017 azzly
 * MIT Licensed
 */
 
'use strict';

/**
 * Module dependencies.
 * @private
 */
const helper = require("../helper");
const CONST = require("../CONST");
const config = require("../config");
const debug = require("../debug")(__filename);
const error = require("../HTTPErrors");
const datasource = require("../datasource");
const cron = require("../cron");
 
/**
 * module.
 */

module.exports = (type)=>{
	if(type !== 'stop'){
		type = 'start';
	}
	
	if(type === 'start' && config.startCron){
		cron.start();
	}
	
  return (req,res,next)=>{
		if(type === 'start'){
			cron.start();
		}else{
			cron.stop();
		}
		res.vinculum.send(`cron ${type}!`);
  }
};